﻿/*
*VMukti -- An open source video conferencing platform.
*
* Copyright (C) 2007 - 2008, VMukti Solutions Pvt. Ltd.
*
* Hardik Sanghvi <hardik@vmukti.com>
*
* See http://www.vmukti.com for more information about
* the VMukti project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, forums and mailing lists
* for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VMukti.Business.WCFServices.SuperNodeServices.BasicHttp;
using VMuktiService;
using VMuktiAPI;

namespace VMukti.Business
{
    public class clsDataBaseChannel
    {
        public static IHttpDataBaseService chHttpDataBaseService;
        public static BasicHttpClient objHttpDataBase = new BasicHttpClient();


        //shilpa code 
        //8-Feb-2008
        public static bool OpenDataBaseClient()
        {
            try
            {
                chHttpDataBaseService = (IHttpDataBaseService)objHttpDataBase.OpenClient<IHttpDataBaseService>("http://" + VMuktiInfo.CurrentPeer.SuperNodeIP + ":80/HttpDataBase");
                chHttpDataBaseService.svcJoin();
                return true;
            }
            catch (System.ServiceModel.EndpointNotFoundException exp)
            {
                exp.Data.Add("My Key", "OpenDataBaseClient()--:--clsDataBaseChannel.cs--:--" + exp.Message + " :--:--");
                ClsException.LogError(exp);
                ClsException.WriteToErrorLogFile(exp);
                VMuktiAPI.VMuktiHelper.CallEvent("GetSuperNodeIP", null, null);
                chHttpDataBaseService = (IHttpDataBaseService)objHttpDataBase.OpenClient<IHttpDataBaseService>("http://" + VMuktiInfo.CurrentPeer.SuperNodeIP + ":80/HttpDataBase");
                chHttpDataBaseService.svcJoin();
                return true;
            }
            catch (System.ServiceModel.CommunicationException exp)
            {
                exp.Data.Add("My Key", "OpenDataBaseClient()--:--clsDataBaseChannel.cs--:--" + exp.Message + " :--:--");
                ClsException.LogError(exp);
                ClsException.WriteToErrorLogFile(exp);
                VMuktiAPI.VMuktiHelper.CallEvent("GetSuperNodeIP", null, null);
                chHttpDataBaseService = (IHttpDataBaseService)objHttpDataBase.OpenClient<IHttpDataBaseService>("http://" + VMuktiInfo.CurrentPeer.SuperNodeIP + ":80/HttpDataBase");
                chHttpDataBaseService.svcJoin();
                return true;
            }
            catch (Exception exp)
            {
                exp.Data.Add("My Key", "OpenDataBaseClient()--:--clsDataBaseChannel.cs--:--" + exp.Message + " :--:--");
                ClsException.LogError(exp);
                ClsException.WriteToErrorLogFile(exp);
                return false;
            }
        }

        //end shilpa code 
        //8-Feb-2008

    }
}
